package com;

import com.cm.res.scanner.MainEntry;
import com.size.check.CheckerEntry;
import com.tinify.loader.TinifyApplication;

import java.util.Arrays;
import java.util.List;

public class TaskEntry {
    private static String TASK_ScanSize  = "ScanSize";
    private static String TASK_ResCheck  = "ScanUnusedRes";
    private static String TASK_Tinify    = "Optimize";

    public static void main(String[] args) {
        if(args.length==0) {
            throw new IllegalArgumentException("Please Input task name [ScanSize|ScanUnusedRes|Optimize]");
        }

        List<String> tasklist = Arrays.asList(TASK_ResCheck, TASK_ScanSize, TASK_Tinify);
        String taskName = args[0];
        if(!tasklist.contains(taskName)){
            throw new IllegalArgumentException("The task "+taskName +" is not supported");
        }

        int len = args.length;
        String[] entrys = new String[len-1];

        for (int i=1;i<len;i++){
            entrys[i-1] = args[i];
        }

        if(TASK_ResCheck.endsWith(taskName)){
            MainEntry.main(entrys);
        }else if(TASK_ScanSize.endsWith(taskName)){
            CheckerEntry.main(entrys);
        } else if(TASK_Tinify.endsWith(taskName)){
            TinifyApplication.main(entrys);
        }
    }
}
